#pragma once
#include <stdint.h>
namespace openitch {
const int szSymbol = 8;

// ITCH 4.* messages
typedef struct itchhdr
{
	itchhdr(const char type) : msgtype(type) {}
	char const msgtype;
	uint32_t time;
} itchhdr_t;

struct timestamp
{
	timestamp() : hdr('T') {}
	itchhdr_t hdr;
};
typedef struct timestamp timestamp_t;

struct sysevent
{
	sysevent() : hdr('S') {}
	itchhdr_t hdr;
	char code;
};
typedef struct sysevent sysevent_t;

struct stkdirectory
{
	stkdirectory() : hdr('R') {}
	itchhdr_t hdr;
	char stock[szSymbol];
	char mktcategory;
	char financialstatusindicator;
	uint32_t roundlotsize;
	bool roundlotsonly;
};
typedef struct stkdirectory stkdirectory_t;

struct stktradingaction
{
	stktradingaction() : hdr('H') {}
	itchhdr_t hdr;
	char stock[szSymbol];
	char tradingstate;
	char reserved;
	char reason[4];
};
typedef struct stktradingaction stktradingaction_t;

struct regshorestriction
{
	regshorestriction() : hdr('Y'){}
	itchhdr_t hdr;
	char stock[szSymbol];
	char regshoaction;
};
typedef struct regshorestriction regshorestriction_t;

struct mktparticipantposition
{
	mktparticipantposition() : hdr('L') {}
	itchhdr_t hdr;
	char mpid[4];
	char stock[szSymbol];
	char primarymktmaker;
	char mktmakermode;
	char mktparticipantstate;
};
typedef struct mktparticipantposition mktparticipantposition_t;

struct addorder
{
	addorder() : hdr('A') {}
	itchhdr_t hdr;
	uint64_t id;
	bool buy;
	uint32_t shares;
	char stock[szSymbol];
	uint32_t price;
};
typedef struct addorder addorder_t;

struct addordermpid
{
	addordermpid() : hdr('F') {}
	itchhdr_t hdr;
	uint64_t id;
	bool buy;
	uint32_t shares;
	char stock[szSymbol];
	uint32_t price;
	char mpid[4];
};
typedef struct addordermpid addordermpid_t;

struct orderexecuted
{
	orderexecuted() : hdr('E') {}
	itchhdr_t hdr;
	uint64_t id;
	uint32_t shares;
	uint64_t matchId;
};
typedef struct orderexecuted orderexecuted_t;

struct orderexecutedwithprice
{
	orderexecutedwithprice() : hdr('C') {}
	itchhdr_t hdr;
	uint64_t id;
	uint32_t shares;
	uint64_t matchId;
	bool printable;
	uint32_t price;
};
typedef struct orderexecutedwithprice orderexecutedwithprice_t;

struct orderreduce
{
	orderreduce() : hdr('X') {}
	itchhdr_t hdr;
	uint64_t id;
	uint32_t shares;
};
typedef struct orderreduce orderreduce_t;

struct orderdelete
{
	orderdelete() : hdr('D') {}
	itchhdr_t hdr;
	uint64_t id;
};
typedef struct orderdelete orderdelete_t;

struct orderreplace
{
	orderreplace() : hdr('U') {}
	itchhdr_t hdr;
	uint64_t oldid;
	uint64_t newid;
	uint32_t shares;
	uint32_t price;
};
typedef struct orderreplace orderreplace_t;

struct trade
{
	trade() : hdr('P') {}
	itchhdr_t hdr;
	uint64_t id;
	char buy;
	uint32_t shares;
	char stock[szSymbol];
	uint32_t price;
	uint64_t matchId;
};
typedef struct trade trade_t;

struct crosstrade
{
	crosstrade() : hdr('Q') {}
	itchhdr_t hdr;
	uint64_t shares;
	char stock[szSymbol];
	uint32_t price;
	uint64_t matchId;
	char crosstype;
};
typedef struct crosstrade crosstrade_t;

struct brokentrade
{
	brokentrade() : hdr('B') {}
	itchhdr_t hdr;
	uint64_t matchId;
};
typedef struct brokentrade brokentrade_t;

// net order imbalance indicator
struct noii
{
	noii() : hdr('I') {}
	itchhdr_t hdr;
	uint64_t pairedshares;
	uint64_t imbalanceshares;
	char imbalancedirection;
	char stock[szSymbol];
	uint32_t farprice;
	uint32_t nearprice;
	uint32_t currentrefprice;
	char crosstype;
	char pricevariationindicator;
};
typedef struct noii noii_t;

// retail price improvement indicator
struct rpii 
{
	rpii() : hdr('G') {}
	itchhdr_t hdr;
	char stock[szSymbol];
	char interestflag;
};
typedef struct rpii rpii_t;

}

